// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()

// 云函数入口函数
exports.main = async (event, context) => {
  let filePath = event.file;
  let pathResult = await cloud.getTempFileURL({
    fileList: [filePath]
  });
  let realFilePath = pathResult.fileList[0].tempFileURL;
  let ocrResult = await cloud.openapi.ocr.idcard({
    type: "photo",
    imgUrl: encodeURIComponent(realFilePath)
  });

  return ocrResult
}